﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class admincp_giaovien : AdminPage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Page_PreRender(object sender, EventArgs e)
    {
        this.FillDataToListview();
    }

    protected void lvGiaoVien_ItemDataBound(object sender, ListViewItemEventArgs e)
    {

    }
    protected void lvGiaoVien_ItemCommand(object sender, ListViewCommandEventArgs e)
    {
        switch (e.CommandName)
        {
            case "EDIT":
                Response.Redirect("qlgiaovien.aspx?hanhdong=capnhat&magiaovien=" + e.CommandArgument.ToString());
                break;
            case "DELETE":
                GiaoVien giaovien = db.GiaoViens.Single(gv => gv.MaGiaoVien == e.CommandArgument.ToString());
                db.GiaoViens.DeleteOnSubmit(giaovien);
                db.SubmitChanges();
                this.FillDataToListview();
                break;
        }
    }

    
    private void FillDataToListview() //Phương thức điền dữ liệu vao Data ListView
    {
        lvGiaoVien.DataSource = db.GiaoViens;
        lvGiaoVien.DataBind();
    }


    protected void ThemMoiGiaoVien(object sender, EventArgs e) //Phương thức thêm mới giáo viên
    {
        Response.Redirect("qlgiaovien.aspx?hanhdong=themmoi");
    }

    
    protected void lvGiaoVien_ItemEditing(object sender, ListViewEditEventArgs e)
    {

    }
    protected void lvGiaoVien_ItemDeleting(object sender, ListViewDeleteEventArgs e)
    {

    }

    
}